package learnProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author jiangfeng 2018/10/25 15:53
 */
public class MeiPoProxy  implements InvocationHandler {

    private Person target;

    public Object  getInstance(Person target) {
        this.target=target;
        Class<? extends Person> clazz = target.getClass();
         return Proxy.newProxyInstance(clazz.getClassLoader(),clazz.getInterfaces(),this);

    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我是媒婆:....................");
        System.out.println("------------");
        this.target.findlove();
//        method.invoke(proxy,args);
        method.invoke(target,args); //传target进去
        System.out.println("---------------");
        System.out.println("开始海选......");
        return null;
    }


}
